use Data_County.dta, clear

// generate outcome variable
gen pp=petition/population*10000


**********************************************************************************************
**********************************************************************************************
****** Table 3: Results from County-Level Analysis based on Gansu and Shaanxi Provinces ******
**********************************************************************************************
**********************************************************************************************

eststo clear
eststo m1:reg pp thirddummy gdpper lnpopulation expper i.capital, robust
estadd local cap "\(\checkmark\)"
estadd local cf "\(\checkmark\)"

eststo m2:ivregress 2sls pp gdpper lnpopulation expper (thirddummy=mindis_US Rdls)  i.capital, robust
estadd local cap "\(\checkmark\)"
estadd local cf "\(\checkmark\)"
estat endog
estat firststage, all forcenonrobust

eststo m3:reg pp thirdproject gdpper lnpopulation expper i.capital, robust
estadd local cap "\(\checkmark\)"
estadd local cf "\(\checkmark\)"

eststo m4:ivregress 2sls pp gdpper lnpopulation expper (thirdproject=mindis_US Rdls)  i.capital, robust
estadd local cap "\(\checkmark\)"
estadd local cf "\(\checkmark\)"
estat endog
estat firststage, all forcenonrobust

esttab m*   using out.txt, nonote nobaselevels keep(thirddummy thirdproject ) b(3) se(3) ///
star(+ 0.1 * 0.05 ** 0.01) label booktabs replace   ///
mtitles("OLS" "2SLS" "OLS" "2SLS" ) mgroup("DV: Online Petitions", pattern(1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(  cf F r2_a N, labels( "County-level controls" "First-stage F" "Adjusted R\(^2\)" "Observations") fmt(0 0 2 0) ) note ()
